<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>聊天室</title>
</head>
<body>
    <div id="contents" style="height:500px;overflow:auto;"></div>
    <div>
        <textarea id="msg"></textarea>
        <a href="javascript:;" onclick="sendMsg()">发送</a>
    </div>
    <script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
    <script type="text/javascript">
        var ws = new WebSocket("ws://192.168.21.48:8000/chat");
        function sendMsg() {
            msg = $("#msg").val();
            $("#msg").val("");
            ws.send(msg);
        };
        ws.onmessage = function (e) {
            $("#contents").append("<p>"+e.data+"</p>");
        };
    </script>
</body>
</html>